package ru.example.netcracker.model.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Alarm extends Task implements Serializable {

    private String id;
    private String name;
    private Date date;
    private String path;
    private boolean show;

    public Alarm() {
    }

    public Alarm(String id, String name, String path, Date date) {
        this.id = id;
        this.name = name;
        this.date = date;
        this.path = path;
    }

    @Override
    public boolean isEnd() {
        return (date.getTime() - System.currentTimeMillis()) > 0;
    }

    @XmlAttribute(name = "id")
    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    @XmlAttribute(name = "name")
    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @XmlAttribute(name = "date")
    @Override
    public Date getDate() {
        return this.date;
    }

    @Override
    public void setDate(Date date) {
        this.date = date;
    }

    @XmlAttribute(name = "path")
    public String getPath() {
        return this.path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    @XmlAttribute(name = "show")
    @Override
    public boolean isShow() {
        return show;
    }

    @Override
    public void setShow(boolean show) {
        this.show = show;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Alarm other = (Alarm) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Alarm{" + "id=" + id + ", name=" + name + ", date=" + date + ", path=" + path + ", show=" + show + '}';
    }
}
